import org.junit.jupiter.api.Test;

import static org.junit.Assert.assertEquals;

public class NGuessNumbe {

    @Test
    void generateAnswer() {
        int s = 4;

        NGuessNumber nGuessNumber = new NGuessNumber();

        assertEquals(s, nGuessNumber.generateAnswer().length);
        System.out.println("数字数量是4，正确");

        //System.out.println(Arrays.toString(nGuessNumber.generateAnswer()));

        int num[] = nGuessNumber.generateAnswer();

        boolean flag = false;
        int numsize = 0;

        for (int i = 0; i < s; i++) {
            if (num[i] >= 0 && num[i] <= 9) {
                numsize = 1;
            } else {
                numsize = 0;
            }
            for (int l = 0; l <= i; l++) {
                if (i != l) {
                    if (num[i] == num[l]) {
                        flag = false;
                    } else {
                        flag = true;
                    }
                    //System.out.println(Arrays.toString(nGuessNumber.generateAnswer()));

                    int num[] = nGuessNumber.generateAnswer();

                    boolean flag = false;
                    int numsize = 0;

                    for (int i = 0; i < s; i++) {
                        if (num[i] >= 0 && num[i] <= 9) {
                            numsize = 1;
                        } else {
                            numsize = 0;
                        }
                        for (int l = 0; l <= i; l++) {
                            if (i != l) {
                                if (num[i] == num[l]) {
                                    flag = false;
                                } else {
                                    flag = true;
                                }
                            }
                        }
                    }

                    assertEquals(true, flag);
                    System.out.println("没有无重复数字，正确");
                    assertEquals(1, numsize);
                    System.out.println("数字都在0-9之间，正确");
                }

                class getPlayerInputTest {
                    @Test
                    void getPlayerInput() {
                        int numsize = 4;

                        NGuessNumber nGuessNumber = new NGuessNumber();

                        assertEquals(numsize, nGuessNumber.guesslist.length);

                        System.out.println("用户输入的数字数量是4，正确");
                    }
                }
                class isWin {
                    @Test
                    void isWin() {
                         NGuessNumber nGuessNumber = new NGuessNumber();

                        if (nGuessNumber.isWin() == true) {
                            assertEquals(true, nGuessNumber.isWin());
                             System.out.println("根据提示信息中A的数量判断玩家是否获胜，如果获胜返回true，否则返回false，返回结果类型正确");
                        } else if (nGuessNumber.isWin() == false) {
                            assertEquals(false, nGuessNumber.isWin());
                             System.out.println("根据提示信息中A的数量判断玩家是否获胜，如果获胜返回true，否则返回false，返回结果类型正确");
                        } else {
                            assertEquals(true, nGuessNumber.isWin());
                            assertEquals(false, nGuessNumber.isWin());
                             System.out.println("根据提示信息中A的数量判断玩家是否获胜，如果获胜返回true，否则返回false，返回结果类型错误");

                        }
                    }
                }
            }
\ No newline at end of file